url_post
This function retrieves the contents of a URL on the Internet and returns it as a string.
string url_post(string url, string parameters)
Parameters:
url
The URL of the file on the Internet that should be retrieved.
parameters
The parameters that should be passed to the server.
Return value:
The data from the server on success, or an error description or blank string on failure (see remarks).
Remarks:
This function will wait until all data has been retrieved from the server before returning. Thus, no large amounts of data should be downloaded using this function as your game will stop responding completely while the operation is in progress. This function is appropriate for actions such as posting scores, where the returned content is minimal.
This function will send what is known as a POST request. A POST request is used in those cases where the data you are sending is longer than is feasible with a GET request.
The URL may not contain any special characters such as spaces or similar. If you wish to include such characters, always encode the URL by calling the url_encode function before attempting to retrieve it from the Internet.
If the http server to which the URL points uses a port other than 80, you will need to include the port after the host name proceeded by a colon. The path on the server (if any) should then follow, proceeded by a slash. Such a URL might look like http://myserver.com:8080/myfile.html.
If multiple calls are made to this function with URL's pointing to the same server, the function will attempt to keep the connection alive for a short while which results in a dramatic speed increase for subsequent calls.
If the network subsystem fails to initialize, the get_last_error function will return -27 and the returned string will be blank.
If an Internet related error occurs, the get_last_error function will return -29 and the returned string will contain a textual description of the error.
This function can be used to retrieve both binary and textual data.
Example:
// Post some data to a dummy site.
void main()
{
string body=url_post("http://www.mysite.com/test.php", "Data=Test&ID=495&Name=Example");
if(get_last_error()!=0)
{
alert("Error", "An error occured.\nDescription: " + body + "");
}
else
{
clipboard_copy_text(body);
alert("Success", "The data was retrieved and has been copied to your clipboard.");
}
}